package com.browan.constellation.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import android.content.Context;

public class AssetsUtil
{

	public static String readAsset(Context c, String pathName)
	{
		StringBuilder builder = new StringBuilder();
		InputStream in = null;
		try
		{
			in = c.getAssets().open(pathName);
			BufferedReader reader = new BufferedReader(new InputStreamReader(in, "utf-8"));
			String line = null;
			while (null != (line = reader.readLine()))
			{
				if (0 == line.length())
				{
					line = "\n\n";
				}
				builder.append(line);
			}
			builder.append("\n\n");
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		finally
		{
			if (null != in)
			{
				try
				{
					in.close();
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
				in = null;
			}
		}
		return builder.toString();
	}
}